#include<vector>
#include<iostream>
using namespace std;

 namespace zjw
{
   template <class T>
   class  less
   {

   public:

	   bool operator()(const T x1,const T x2)
	   {
		   return x1 < x2;
	  
	   }





   };
   template <class T>
   class  greater
   {

   public:

	   bool operator()(const T x1, const T x2)
	   {
		   return x1 > x2;

	   }





   };

   template <class T,class Container=vector<T>,class Compare=greater<T>>
   class priority_queue
   {
   public:
	   priority_queue() = default;

	   template <class InputIterator>
	   priority_queue(InputIterator first, InputIterator last)
	   {

		   while (first != last)
		   {
			   push(*first);
			   first++;
		   }



	   }


	   void adjustup(int child)
	   {
		   int parent = (child - 1) / 2;
		   while (child > 0)
		   {
		      
			   if (_comp(_con[child], _con[parent]))
			   {
				   swap(_con[child], _con[parent]);
				   child = parent;
				   parent = (child - 1) / 2;



			   }
			   else
			   {

				   break;


			   }

		   }
	 
	   }
	   void adjustdown(int parent)
	   {
		   int child = parent * 2 + 1;
		   while (child < _con.size())
		   {
		    
			   if (child + 1 < _con.size() && _comp(_con[child+1], _con[child]))
			   {
				   child += 1;

			   }
			   if (_comp(_con[child], _con[parent]))
			   {
				   swap(_con[child], _con[parent]);
				   parent = child;
				   child = parent * 2 + 1;

			   }
			   else
			   {

				   break;

			   }


		   }
	   

	   }

	   bool empty()
	   {
	   
		   return _con.empty();
	   
	   
	   
	   }
	   size_t size()
	   {
	   
		   return _con.size();
	   
	   
	   }
	   
	   T& top()
	   {
	   
		   return _con.front();
	   
	   
	   }

	   void push(T x)
	   {
		   _con.push_back(x);
		   adjustup(_con.size() - 1);
		   
	   }

	   void pop()
	   {
	   
		   swap(_con[0], _con[_con.size() - 1]);
		   _con.pop_back();
		   adjustdown(0);


	   
	   
	   }


   private:
	   Container _con;
	   Compare _comp;



   };
 

};

int main()
{
	zjw::priority_queue<int>st;
	// priority_queue

	st.push(1);
	st.push(7);
	st.push(6);
	st.push(4);
	st.push(3);
	st.push(8);


	while (!st.empty())
	{
		int  ret = st.top();
		st.pop();
		cout << ret << " ";



	}




}